/** @file gui.h
    @brief The minimalistic GUI */

#ifndef G3_GUI_H
#define G3_GUI_H

#include "gui/gui_image.h"
#include "gui/gui_group.h"
#include "gui/gui_button.h"
#include "gui/gui_editbox.h"
#include "gui/gui_scrollbar.h"

namespace G3 {
/** Minimalistic graphical user interface */
namespace GUI {

/** @class GUI
    @brief The GUI class singleton */
class GUI: public SINGLETON<GUI> {
	public:
        /**
            @brief Constructor
        */
		GUI ();
		/**
            @brief Destructor
		*/
		~GUI ();

        /** Pointer to the one active widget */
		WIDGET *ActiveWidget;

        /** The root widget that encloses all other widgets */
		WIDGET Root;
        /** All label widgets */
		vector<LABEL *> pLabels;
		/** All groups */
		vector<GROUP *> pGroups;
		/** All buttons */
		vector<BUTTON *> pButtons;
		/** All editboxes */
		vector<EDITBOX *> pEditBoxes;
		/** All scrollbars */
		vector<SCROLLBAR *> pScrollbars;
		/** All unknown widgets */
		vector<WIDGET *> pUnknown;

        /**
            @brief Attaches the GUI an input
        */
		void AttachInput (G3::INPUT *aInput);

        /**
            @brief Adds a widget to the gui
            @param[in] aParent Parent of the widget. If it's NULL, then root is considered as the widget's parent.
            @param[in] aWidget Pointer to the widget to be added
            @return Pointer to the recently added widget
        */
		WIDGET *AddWidget (WIDGET *aParent, WIDGET *aWidget);

        /**
            @brief Sets focus on a particular widget
            @param[in] widget Pointer to the widget to be focused
        */
		void SetFocus (WIDGET *widget);

        /**
            @brief Draws the whole gui
            @param[in] aElapsedTime Elapsed time since the last call
        */
		void Draw (float aElapsedTime = 0.0f);
};

/** The main GUI singleton instance */
extern GUI MainGui;

/**
    @brief GUI key-down event callback
    @param[in] Input Pointer to the input class
    @param[in] keysym Pointer to the class that contains information about the recently pressed key
    @param[in] aElapsedTime Elapsed time since the last call
*/
void OnKeyDown (G3::INPUT *Input, SDL_keysym* keysym, float aElapsedTime);
/**
    @brief GUI key-up event callback
    @param[in] Input Pointer to the input class
    @param[in] keysym Pointer to the class that contains information about the recently pressed key
    @param[in] aElapsedTime Elapsed time since the last call
*/
void OnKeyUp (G3::INPUT *Input, SDL_keysym* keysym, float aElapsedTime);
/**
    @brief GUI mouse-move event callback
    @param[in] Input Pointer to the input class
    @param[in] Event Pointer to the class that contains information about the mouse state
    @param[in] aElapsedTime Elapsed time since the last call
*/
void OnMouseMove (G3::INPUT *Input, SDL_Event* Event, float aElapsedTime);
/**
    @brief GUI mouse-down event callback
    @param[in] Input Pointer to the input class
    @param[in] Event Pointer to the class that contains information about the mouse state
    @param[in] aElapsedTime Elapsed time since the last call
*/
void OnMouseDown (G3::INPUT *Input, SDL_Event* Event, float aElapsedTime);
/**
    @brief GUI mouse-up event callback
    @param[in] Input Pointer to the input class
    @param[in] Event Pointer to the class that contains information about the mouse state
    @param[in] aElapsedTime Elapsed time since the last call
*/
void OnMouseUp (G3::INPUT *Input, SDL_Event* Event, float aElapsedTime);

}
}

#endif

